package com.atguigu.webflux.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.CorsRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;

/**
 * @author Jungle
 * @create 2024-01-13 17:16
 */
@Configuration
public class MyWebConfiguration {
    @Bean
    public WebFluxConfigurer webFluxConfigurer() {
        return new WebFluxConfigurer() {
            // 配置跨域
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**")
                        .allowedHeaders("*")  //请求头
                        .allowedMethods("*") //方法
                        .allowedOrigins("localhost");  //允许来源
            }
        };
    }
}
